﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;

namespace OverStore.Runtime.ObjectRepository.Attacher
{
    /// <summary>
    /// Contains information is required during attaching instance.
    /// </summary>
    /// <typeparam name="TIdentifier">The type of the identifier.</typeparam>
    public sealed class InstanceAttachInfo<TIdentifier>
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="InstanceAttachInfo&lt;TIdentifier&gt;"/> class.
        /// </summary>
        /// <param name="identifier">The identifier.</param>
        /// <param name="isInstanceNew">if set to <c>true</c> [is instance new].</param>
        /// <param name="generateNewIdentifier">if set to <c>true</c>, the new identifier should be generated if instance does not exist in data storage.</param>
        /// <param name="areInstanceDataChanged">if set to <c>true</c> if data of instance being attached are changed.</param>
        public InstanceAttachInfo(TIdentifier identifier, bool isInstanceNew, bool generateNewIdentifier, bool areInstanceDataChanged)
        {
            Identifier = identifier;
            IsInstanceNew = isInstanceNew;
            GenerateNewIdentifier = generateNewIdentifier;
            AreInstanceDataChanged = areInstanceDataChanged;
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="InstanceAttachInfo&lt;TIdentifier&gt;"/> class.
        /// </summary>
        public InstanceAttachInfo() { }

        /// <summary>
        /// Gets the identifier for the instace.
        /// </summary>
        public TIdentifier Identifier { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether an instance with such key is not exist in data storage.
        /// </summary>
        public bool IsInstanceNew { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether new identifier should be generated for instance if instance is not exist in data storage.
        /// </summary>
        public bool GenerateNewIdentifier { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether data of instance being attached are changed.
        /// </summary>
        public bool AreInstanceDataChanged { get; set; }
    }
}
